import { PageReq, PageRes } from '@/api/types'
import request from '@/utils/request'
import { PurchaseModel } from '@/api/model/purchase-model'

// 获取采购列表
export function purchasePageApi(data: PageReq<Partial<any>>) {
  return request<PageRes<any>>({
    url: '/purchase/page',
    method: 'post',
    data
  })
}

// 新增采购
export function addPurchaseApi(data: Partial<PurchaseModel>) {
  return request({
    url: '/purchase/add',
    method: 'post',
    data
  })
}

// 更新采购
export function editPurchaseApi(data: Partial<PurchaseModel & { id: number }>) {
  return request({
    url: '/purchase/edit',
    method: 'post',
    data
  })
}

// 删除采购
export function delPurchaseApi(data: { id: number }) {
  return request({
    url: '/purchase/del',
    method: 'post',
    data
  })
}

// 获取采购列表
export function getPurchaseListApi(data: {
  isInStore: boolean
  orgId: number
}) {
  return request({
    url: '/purchase/getPurchaseList',
    method: 'post',
    data
  })
}

// 获取采购详情
export function getPurchaseDetailApi(data: { id: number }) {
  return request({
    url: '/purchase/getPurchaseDetail',
    method: 'post',
    data
  })
}
